
//
//  bangDing.m
//  DJS
//
//  Created by 浪尖渝力 on 2018/2/9.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "bangDingView.h"
#import "BangDing2ViewController.h"
@implementation bangDingView

-(void)creatView{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    
    self.backgroundColor=[UIColor whiteColor];
    
    UIView *nameView=[UIView new];
    [self addSubview:nameView];
    [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(NAV_HEIGHT);
        make.height.mas_equalTo(55);
    }];
    
    UILabel *nameLabel=[UILabel new];
    [nameView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
    }];
    nameLabel.text=@"持卡人姓名";
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    nameLabel.font=[UIFont systemFontOfSize:17];
    
    UILabel *nameLabel2=[UILabel new];
    [nameView addSubview:nameLabel2];
    [nameLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(0);
    }];
    NSString *waiter_name=[userDic objectForKey:@"waiter_name"];
    if ([ZQTools charIsNil:waiter_name]) {
        waiter_name=@"";
    }
    nameLabel2.text=waiter_name;
    nameLabel2.textColor=ColorWithRGB(149, 149, 149);
    nameLabel2.font=[UIFont systemFontOfSize:17];
    
    UIView *xianView=[UIView new];
    [self addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.right.mas_equalTo(nameLabel2);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(nameView.mas_bottom);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *nameView2=[UIView new];
    [self addSubview:nameView2];
    [nameView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(xianView.mas_bottom);
        make.height.mas_equalTo(55);
    }];
    
    UILabel *NumLabel=[UILabel new];
    [nameView2 addSubview:NumLabel];
    [NumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
    }];
    NumLabel.text=@"银行卡号";
    NumLabel.textColor=ColorWithRGB(49, 49, 49);
    NumLabel.font=[UIFont systemFontOfSize:17];
    
    
    _numText=[UITextField new];
    [nameView2 addSubview:_numText];
    [_numText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.left.mas_equalTo(150);
        make.height.mas_equalTo(35);
        make.centerY.mas_equalTo(0);
    }];
    _numText.placeholder=@"请输入您的银行卡账号";
    _numText.textColor=ColorWithRGB(149, 149, 149);
    _numText.textAlignment=NSTextAlignmentRight;
    _numText.delegate=self;
    _numText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView2=[UIView new];
    [self addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.right.mas_equalTo(nameLabel2);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(nameView2.mas_bottom);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    
    UIView *nameView3=[UIView new];
    [self addSubview:nameView3];
    [nameView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(nameView2.mas_bottom);
        make.height.mas_equalTo(55);
    }];
    
    UILabel *NumLabel2=[UILabel new];
    [nameView3 addSubview:NumLabel2];
    [NumLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
    }];
    NumLabel2.text=@"手机号";
    NumLabel2.textColor=ColorWithRGB(49, 49, 49);
    NumLabel2.font=[UIFont systemFontOfSize:17];
    
    _phoneText=[UITextField new];
    [nameView3 addSubview:_phoneText];
    [_phoneText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.left.mas_equalTo(150);
        make.height.mas_equalTo(35);
        make.centerY.mas_equalTo(0);
    }];
    _phoneText.placeholder=@"请输入银行卡绑定的手机号";
    _phoneText.textColor=ColorWithRGB(149, 149, 149);
    _phoneText.textAlignment=NSTextAlignmentRight;
    _phoneText.delegate=self;
    _phoneText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView3=[UIView new];
    [self addSubview:xianView3];
    [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.right.mas_equalTo(nameLabel2);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(nameView3.mas_bottom);
    }];
    xianView3.backgroundColor=_LightGrey;
    
    
    UIButton *btn=[UIButton new];
    [self addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(_mainW-40);
        make.top.mas_equalTo(xianView3.mas_bottom).mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
    btn.layer.cornerRadius=10;
    btn.backgroundColor=_backgroundColor;
    [btn setTitle:@"下一步" forState:0];
    [btn setTitleColor:[UIColor whiteColor] forState:0];
    [btn addTarget:self action:@selector(tiJiao:) forControlEvents:UIControlEventTouchUpInside];

}
-(IBAction)tiJiao:(id)sender{
    NSString *numStr=_numText.text;
    NSString *phoneText=_phoneText.text;
    if ([ZQTools charIsNil:numStr]) {
        [ZQTools svpInfo:@"银行卡号不能为空"];
        return;
    } if (![ZQTools isMobileNumber:phoneText]) {
        [ZQTools svpInfo:@"你输入的手机号不正确"];
        return;
    }
    BangDing2ViewController *bangDing=[[BangDing2ViewController alloc] init];
    bangDing.numStr=numStr;
    bangDing.phoneStr=phoneText;
    [ZQTools pushNextViewController:self.viewController andRootController:bangDing];
    
}
@end
